package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.data.entity.ProjectTravel;
import com.nbsaas.boot.project.api.domain.simple.ProjectTravelSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
 * 出差-列表对象转换器
 */

public class ProjectTravelSimpleConvert implements Converter<ProjectTravelSimple, ProjectTravel> {


    @Override
    public ProjectTravelSimple convert(ProjectTravel source) {
        ProjectTravelSimple result = new ProjectTravelSimple();

        result.setBeginDate(source.getBeginDate());
        result.setNote(source.getNote());
        result.setFollowUser(source.getFollowUser());
        result.setAddress(source.getAddress());

        try {
            if (source.getProject() != null) {
                result.setProject(source.getProject().getId());
            }
        } catch (Exception ignored) {
        }

        result.setId(source.getId());

        try {
            if (source.getProject() != null) {
                result.setProjectName(source.getProject().getName());
            }
        } catch (Exception ignored) {
        }

        result.setAddDate(source.getAddDate());
        result.setLastDate(source.getLastDate());


        return result;
    }

}